import 'package:flutter/material.dart';
import 'package:sl_flutter/pages/login/login.dart';
import 'package:sl_flutter/pages/tabs/index.dart';

import 'package:sl_flutter/pages/setting/setting.dart';
import 'package:sl_flutter/utils/tokenManager.dart';

void main() async {
  // 确保 Flutter 框架初始化
  WidgetsFlutterBinding.ensureInitialized();
  await TokenManager().init();
  runApp(
    MaterialApp(
      initialRoute: TokenManager().getToken() == null ? '/login' : '/tabs',
      routes: {
        '/login': (context) => Login(),
        '/setting': (context) => SystemSettingsPage(),
      },
      onGenerateRoute: (settings) {
        return MaterialPageRoute(builder: (context) => Tabs());
      },
    ),
  );
}
